<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="robots" content="all,follow">

  <title>系统登录页面</title>
  <link rel="shortcut icon" href="${pageContext.request.contextPath}/static/public/img/favicon.ico">

  <!-- global stylesheets -->
  <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed" rel="stylesheet">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/public/css/bootstrap.min.css">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/public/font-awesome-4.7.0/css/font-awesome.min.css">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/public/css/font-icon-style.css">
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/public/css/style.default.css" id="theme-stylesheet">

  <!-- Core stylesheets -->
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/public/css/pages/login.css">

</head>
<body>
      <section class="hero-area">
        <div class="overlay"></div>
        <div class="container">
          <div class="row">
            <div class="col-md-12 ">
              <div class="contact-h-cont">
                <h3 class="text-center"><img src="${pageContext.request.contextPath}/static/public/img/logo.png" class="img-fluid" alt=""></h3><br>
                <form  >
                  <div class="form-group">
                    <label for="username">用户名：</label>
                    <input type="text" class="form-control" id="username" name="username" placeholder="Enter Username">
                  </div>
                  <div class="form-group">
                    <label for="exampleInputEmail1">密码：</label>
                    <input class="form-control" type="password" value="" id="password" name="password" id="example-password-input">
                  </div>
                  <button type="button" class="btn btn-general btn-blue" role="button" id="mybtn"><i fa fa-right-arrow></i>登 录</button>
                </form>
              </div>
            </div>
          </div>
        </div>
      </section>

      <!--Global Javascript -->
      <script src="${pageContext.request.contextPath}/static/public/js/jquery.min.js"></script>
      <script src="${pageContext.request.contextPath}/static/public/js/tether.min.js"></script>
      <script src="${pageContext.request.contextPath}/static/public/js/bootstrap.min.js"></script>
</body>
</html>
<script>
  //按钮单机事件
  $("#mybtn").click(function(){
      //用户信息验证
      var username=$.trim($("#username").val());
      var password=$.trim($("#password").val());
      var userinfo={"username":username,"userpassword":password};
      if(username==""||password==""){
          alert("用户名或密码为空!");
      }else{
          $.ajax({
              url: '${pageContext.request.contextPath}/user/validate',
              type: "post",
              data: JSON.stringify(userinfo),
              contentType:'application/json;charset=utf-8',
              dataType: "json",
              success: function(result){
                  console.log("validate结果:",result.sequencenum);
                  window.location.href="${pageContext.request.contextPath}/user/login?sequencenum="+result.sequencenum;
              },
              error: function(){
                  $("#password").val("");
                  alert("用户名或密码错误，请重新输入！");

              }
          });

      }

  });

</script>